<?php 
namespace Rac\Model;
use Think\Model;
use Think\Page;
class NavModel extends Model {
	
	// 返回有权限的菜单
	public function auth_nav($auth_list) {
		if (empty($auth_list)) {
			return array();
		}
		$lang = LANG_SET;
		$map = array('nav_url'=>array('IN', $auth_list));
		$data = $this->where($map)->order('sort ASC')->select();
		$oneRes = array();
		$towRes = array();
		foreach ($data as $value) {
			if ($value['pid'] == '0') {
				$oneRes[] = $value;
			} else {
				$towRes[] = $value;
			}
		}
		
		foreach ($oneRes as $key=>$value) {
			if($lang=='en-us'){
				$oneRes[$key]['lang'] = $oneRes[$key]['nav_english_name'];
			}
			
			if($lang=='zh-cn'){
				$oneRes[$key]['lang'] = $oneRes[$key]['nav_name'];
			}
			
			foreach ($towRes as $v) {								
				if($lang=='en-us'){
					$v['lang'] = $v['nav_english_name'];
				}
					
				if($lang=='zh-cn'){
					$v['lang'] = $v['nav_name'];
				}
				
				if ($value['id'] == $v['pid']) {
					$oneRes[$key]['child'][] = $v;
				}
			}
		}        
		return $oneRes;
	}
}


?>